package com.lbn.monitor;

import android.app.Notification;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.util.Log;
import android.widget.RemoteViews;
import android.widget.Toast;

import com.free.framework.base.PluginApp;
import com.free.framework.lib.utils.PrefsMgr;
import com.google.gson.Gson;
import com.lbn.monitor.api.model.User;
import com.lbn.monitor.util.Constant;
import com.lbn.monitor.util.UIHandler;
import com.lbn.monitor.util.UPushSdk;


/**
 * @author 李炳南
 * @date 2017/3/6
 */
public class App extends PluginApp {


    private static User user;

    private static App app;

    @Override
    public void onCreate() {
        super.onCreate();
        app = this;
        UPushSdk.instance().init(this);
        UIHandler.initUIHanlder(getMainLooper());
        String userJson = (String)PrefsMgr.get(this,Constant.USER_INFO,"");
        user = new Gson().fromJson(userJson,User.class);
    }

    public static void clearUser() {
        user = null;
        PrefsMgr.remove(app,Constant.USER_INFO);
    }

    public static void setUser(User user) {
        App.user = user;
    }

    public static boolean isLogin(){
        return user!=null&&user.getId()!=null;
    }

    public static User getUser(){
        return user;
    }

}
